package ;

import Observer;

/**
 * ...
 * @author 
 */

class Counter 
{
	private var v: Int;
	private var view: Observer;
	

	public function new(?value: Int) 
	{
		v = value == null? 0 : value;
	}
	
	
	public function Attach(o: Observer)
	{
		view = o;
	}

	
	inline public function Get(): Int
	{
		return v;
	}


	inline public function Set(value: Int)
	{
		v = value;
		
		if (view != null) {
			view.Update(value);
		}
	}
	
	
	inline public function Add(value: Int)
	{
		Set(v + value);
	}
	
}